#include <gtest/gtest.h>
#include "binary_search_tree.h"

TEST(HelloTest, BTREE_Insert) {
    EXPECT_EQ(ERR, BTREE_Insert(NULL, NULL));

    BTREE_ROOT treeRoot;
    treeRoot.root = (BTREE_NODE*)MALLOC(sizeof(BTREE_NODE));
    (VOID)memset(treeRoot.root, 0, sizeof(BTREE_NODE));
    treeRoot.root->val = 10;
    BTREE_NODE *node = (BTREE_NODE*)MALLOC(sizeof(BTREE_NODE));
    (VOID)memset(node, 0, sizeof(BTREE_NODE));
    node->val = 20;
    EXPECT_EQ(OK,             BTREE_Insert(&treeRoot, node));
    EXPECT_EQ(NULL,           treeRoot.root->left);
    EXPECT_EQ(node->val,      treeRoot.root->right->val);
    EXPECT_EQ(treeRoot.root,  treeRoot.root->right->p);
}